package com.societyGames.catExercises
{
	import com.greensock.TweenNano;
	import com.societyGames.action.Action;
	
	import flash.display.DisplayObject;
	import flash.display.DisplayObjectContainer;

	public class BuyClothingAction extends Action
	{
		private var _cat:DisplayObjectContainer;
		private var _clothing:DisplayObject;
		private var _duration:Number; 
		
		public function BuyClothingAction(cat:DisplayObjectContainer, clothing:DisplayObject, duration:Number = 0.25)
		{
			this._cat = cat;
			this._clothing = clothing;
			this._duration = duration;
		}
		
		public override function startAction():void
		{
			this._cat.addChild(this._clothing);
			this._clothing.alpha = 0;
			TweenNano.to(this._clothing, _duration, {alpha:1, onComplete:onComplete});	
		}
		
		private function onComplete():void
		{
			this._completeEventObject.dispatchEvent();
		}
	}
}